package com.multipleThread.myRestaurant;

import lombok.Data;
import sun.tools.jconsole.Tab;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;

/**
 * @author 罗俊华
 * @date 2021/4/29 - 1:44 下午
 */
@Data
public class RestaurantPlus {
    //  记录全店的每桌分别对应的订单是什么
    private final Map<Table, OrderTicket> orderTickets = new ConcurrentHashMap<>();
    //  新订单（待烹饪）
    private final BlockingQueue<Menu> newOrderedMenuQueue = new LinkedBlockingDeque<>();
    // 空闲的服务员队列
    private BlockingQueue<WaitingPerson> idleWaitingPeople = new LinkedBlockingQueue<>();

    public RestaurantPlus(int chefCount, int waitingPersonCount, int receptionistCount) {
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < chefCount; i++) {
            executorService.execute(new Chef(this));
        }

        for (int i = 0; i < waitingPersonCount; i++) {
            idleWaitingPeople.add(new WaitingPerson(this));
        }

        for (int i = 0; i < receptionistCount; i++) {
            executorService.execute(new Receptionist(executorService, this));
        }
    }

    public static void main(String[] args) {
        new RestaurantPlus(10,5,8);
    }
}
